<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .font {
        color: red;
        font-size: 30px;
      }
      .green {
        color: green;
      }
      .font-weight {
        font-weight: 900;
      }
      .abc {
        font-style: oblique;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h2>class的绑定</h2>
      <!-- vue给class和style专门做了v-bind的增强，允许里面写对象或者数组 -->
      <!-- <p v-bind:class="show && 'font'">hello vue!</p> -->

      <!-- 对象语法里面key表示类名，value表示变量或者表达式 -->
      <!-- 如果类名中有连字符，那么需要加上引号 -->

      <!-- class和:class是会合并的, 其他的属性都是会覆盖的 -->
      <p :class="{ font: show, 'font-weight': count === 1 }" class="abc">
        hello vue!
      </p>
      <p :class="[className, className2]">hello vue!</p>
      <button v-on:click="className = 'green'">btn</button>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            show: true,
            count: 1,
            // obj: {
            //   font: true,
            //   'font-weight': false
            // }

            className: "font",
            className2: "font-weight",
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
